package com.gvalentin.speedogradient.data;

import android.location.Location;

public class CalculatorDistance implements Calculator<Double> {
	
	// Distance (meters)
	protected double distance = 0;

	/**
	 * Update the current location
	 * @see com.gvalentin.SpeedoGradient.data.Calculator#update(android.location.Location, android.location.Location)
	 */
	@Override
	public void update(Location previous, Location current) {
		if (previous != null && current != null) {
			distance += current.distanceTo(previous);
		}
	}

	/**
	 * Get the calculated distance
	 * @see com.gvalentin.SpeedoGradient.data.Calculator#getData()
	 */
	@Override
	public Double getData() {
		return distance;
	}
}
